//C19:Listing 19.12 -- for_each().
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

template<class T>
class Print
{
    public:
        void operator()(const T& t)
        {
            cout << t << " " << endl;
        }
};

int main(void)
{
    Print<int> DoPrint;
    vector<int> vInt(5);

    for (int i = 0; i < 5; i++)
    {
        vInt[i] = i * 3;
    }

    cout << "for_each()" << endl;
    for_each(vInt.begin(), vInt.end(), DoPrint);
    cout << endl;
}